package spring.core.examples.java;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import spring.core.extensions.SpringApplicatonContext;

/**
 * Provides a Spring context that scans a specific directory for Spring meta
 * data.
 */
public class CoreJavaContext extends SpringApplicatonContext {
	private static CoreJavaContext INSTANCE = new CoreJavaContext();

	/**
	 * Gets the single instance of ValidatorContext.
	 * 
	 * @return single instance of ValidatorContext
	 */
	public static CoreJavaContext getInstance() {
		return CoreJavaContext.INSTANCE;
	}

	/**
	 * @see spring.core.extensions.SpringApplicatonContext#registerDefaultApplicatonContext()
	 */
	@Override
	protected void registerDefaultApplicatonContext() {
		AnnotationConfigApplicationContext myContext = new AnnotationConfigApplicationContext();
		myContext.getEnvironment().setActiveProfiles("production");
		myContext.scan("spring.core.examples.java.configuration");
		myContext.refresh();
		this.setApplicationContext(myContext);
		System.out
				.println("Verwende Spring Kontext für Konfiguration über Java Klassen.");
	}

}
